<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\cdc\cost\flow;

use app\enum\ServiceCostEnum;
use app\model\CostTaskAccountModel;
use app\service\cdc\cost\CostService;
use app\service\cdc\cost\PullService;

class AccountService extends CostService implements FlowInterface
{
    /**
     * @var int 操作类型
     */
    protected int $taskAccountType = ServiceCostEnum::TASK_TYPE_ACCOUNT;

    /**
     * @var int|mixed
     */
    protected ?PullService $pullService;

    /**
     * 获取媒体数据.
     * @param CostTaskAccountModel $model 任务模型
     */
    protected function getCostData(CostTaskAccountModel $model): bool
    {
        $today = intval(date('Ymd'));
        if ($model->getAttr('stat_date') == $today) {// 拉取报表
            return $this->pullService->getAccountReportList($model);
        }
        return $this->pullService->getAdvertiserDailyFlow($model);
    }
}
